# numbers = [2,3,4]
# target = 6
# length = len(numbers) #3
# i=0
# left=numbers[i] #0,2
# right=numbers[length-1-i] #2,4
# while left+right!=target:
#     i+=1
#     if left+right>target:
#         right=numbers[length-1-i]
#     else:
#         left=numbers[i]  #left+right<target
# print(left,right)
from typing import List


# numbers = [-1,0]
# target = -1
# length = len(numbers) #3
# i=0
# left=i
# right =length-1-i
# while numbers[left]+numbers[right]!=target:
#     i+=1
#     if numbers[left]+numbers[right]>target:
#         right=length-1-i
#     if numbers[left]+numbers[right]<target:
#         left=i
# print(left+1,right+1)





# class Solution:
#     def twoSum(self, numbers: List[int], target: int) -> List[int]:
#         length = len(numbers)
#         i = 0
#         left = i
#         right = length - 1 - i  #❌这个地方错误
#         while numbers[left] + numbers[right] != target:
#             i += 1
#             if numbers[left] + numbers[right] > target:
#                 right = length - 1 - i
#             if numbers[left] + numbers[right] < target:
#                 left = i
#
#
#         return [left + 1, right + 1]



class Solution:
    def twoSum(self, numbers: List[int], target: int) -> List[int]:
        lenght = len(numbers)
        left=0
        right=lenght-1
        while left<right:
            sum=numbers[left]+numbers[right]
            if sum==target:
                return [left+1,right+1]
            if sum>target:
                right-=1
            else:
                left+=1
